Skip to content

Conversation

tarcieri
Copy link
Member

Following the pattern of #1921, removes the lifetime from the struct, instead changing OctetStringRef to a proper reference type to be used as &OctetStringRef.

This makes it possible to impl Borrow<OctetStringRef> for OctetString and impl ToOwned for OctetStringRef, so they can work with Cow.

cc @dishmaker

@tarcieri tarcieri requested a review from baloo August 18, 2025 14:22
@tarcieri
Copy link
Member Author

Custom derive needs to be updated to be aware that certain types are reference types and need to be used as e.g. <&OctetStringRef>::decode instead of OctetStringRef::decode

@tarcieri tarcieri force-pushed the der/remove-octet-string-ref-lifetime branch from 8cee1e0 to 2359ca5 Compare August 18, 2025 14:38
@tarcieri tarcieri force-pushed the der/remove-octet-string-ref-lifetime branch 4 times, most recently from 54b1fbb to 2a06eca Compare September 15, 2025 19:01
@tarcieri
Copy link
Member Author

Well, with a few hacks this is green. I think the hacks might be OK to merge with, but we'd ideally want to get them removed before a final release.

@tarcieri tarcieri changed the title [WIP] der: remove lifetime from OctetStringRef der: remove lifetime from OctetStringRef Sep 15, 2025
@tarcieri tarcieri marked this pull request as ready for review September 15, 2025 19:27
Comment on lines +8 to +10
// TODO(tarcieri): custom derive hack until the logic is updated to support `&'a` reference types
#[doc(hidden)]
pub type OctetStringRef2<'a> = &'a OctetStringRef;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is one of the hacks. I didn't implement special case support for &'a MyRef types in der_derive yet, so this hack lets it use the old syntax.

Following the pattern of #1921, removes the lifetime from the struct,
instead changing `OctetStringRef` to a proper reference type to be used
as `&OctetStringRef`.

This makes it possible to `impl Borrow<OctetStringRef> for OctetString`
and `impl ToOwned for OctetStringRef`, so they can work with `Cow`.
@tarcieri tarcieri force-pushed the der/remove-octet-string-ref-lifetime branch from 2a06eca to 77c4d20 Compare September 15, 2025 19:30
@tarcieri
Copy link
Member Author

tarcieri commented Sep 15, 2025

Gonna land this. We can work through custom derive support separately. I'll make an issue about it.

Edit: opened #2039

@tarcieri tarcieri merged commit 3d56da5 into master Sep 15, 2025
107 checks passed
@tarcieri tarcieri deleted the der/remove-octet-string-ref-lifetime branch September 15, 2025 19:43
tarcieri added a commit that referenced this pull request Sep 15, 2025
This is a temporary type introduced in #1998 until `der_derive` can be
updated to use the new type shape (see #2039).
tarcieri added a commit that referenced this pull request Sep 15, 2025
This is a temporary type introduced in #1998 until `der_derive` can be
updated to use the new type shape (see #2039).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants